<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<x:parse xml="${param.xmlstr}" var="xmlData" />
<div class="t_bar">
	<span class="color_red">*</span>国外专利申请明细表
</div>



<table id="tblTechnologys" cellpadding="0" class="table01" width="100%"
	border="0" cellpadding="0" style="*border-bottom: #a1c0dc 1px solid;">
	<thead>
		<tr style="border: 1px solid #B7D1E6">
			<th class="TblHead" align="center" width="30px">选择 <input
				type="hidden" name="technologys/technologys_ispatent_value" id="technologys_ispatent_value"
				value="<x:out select="$xmlData/data/technologys/technologys_ispatent_value" />" />
				<c:set var="technologys_ispatent">
					<x:out
						select="$xmlData/data/technologys/technologys_ispatent_value" />
				</c:set></th>
			<th class="TblHead" align="center" width="30px">序号</th>
			<th class="TblHead" align="center" width="200px">发明专利名称</th>
			<th class="TblHead" align="center" width="100px">专利申请途径</th>
			<th class="TblHead" align="center" width="100px">申请日</th>
			<th class="TblHead" align="center" width="100px">授权日</th>
			<th class="TblHead" align="center" width="100px">专利号</th>
			<th class="TblHead" align="center" width="100px">专利授权国家</th>
			<th class="TblHead" align="center" width="100px">是否首件授权专利</th>
		</tr>
	</thead>

	<tbody id="tab">
		<tr style="display: none">
			<td width="30px" align="center"><input type="radio" class="radiobutton"
				name="selTechnologys" onclick="movePrev2('tblTechnologys');">&nbsp;
			</td>
			<td align="center" width="30px"><span
				name="technologys|technology[0]@seq_no">[index]</span>&nbsp;
			</td>
			<td align="center" width="200px"><input
				name="technologys|technology[0]|name" class="required input_text "
				 style="width: 150px" label="发明专利名称" value="">&nbsp;
			</td>
			<td align="center" width="100px"><input
				name="technologys|technology[0]|way" class="required input_text "
				maxlength=50 style="width: 80px" label="专利申请途径" value="">&nbsp;
			</td>
			<td align="center" width="100px"><input
				id="technology_application_date_[0]"
				name="technologys|technology[0]|application_date" label="申请日"
				value="" class="required input_text date dateCompareBeforeE:technology_application_date_[0]:technology_authorized_date_[0]" style="width: 64px" />&nbsp;
			</td>
			<td align="center" width="100px"><input
				id="technology_authorized_date_[0]"
				name="technologys|technology[0]|authorized_date" label="授权日"
				value="" class="required input_text date " style="width: 64px" />&nbsp;
			</td>
			<td align="center"><input
				name="technologys|technology[0]|zhuanli_no"
				class="required input_text " maxlength=50 style="width: 80px"
				label="专利号" value="">&nbsp;
			</td>
			<td align="center" width="100px"><input
				name="technologys|technology[0]|country"
				class="required input_text " maxlength=50 style="width: 80px"
				label="专利授权国家" value="">&nbsp;
			</td>
			<td align="center" width="100px"><input type="radio"
				value="[index]" name="technologys_ispatent"
				id="technologys_ispatent_[index]"
				onclick="changeTable('tblTechnologys');initControlValue2(this.id);movePrev2('tblTechnologys')" />&nbsp;
			</td>
			<c:set value="0" var="index" scope="page" />
			<x:forEach select="$xmlData/data/technologys/technology"
				var="technology">

				<c:choose>
					<c:when test="${index<10}">
						<c:set value="0" var="flag" scope="page" />
					</c:when>
					<c:otherwise>
						<c:set value="" var="flag" scope="page" />
					</c:otherwise>
				</c:choose>
				<tr>
					<td width="30px" align="center"><input type="radio"
						class="radiobutton" name="selTechnologys" onclick="movePrev2('tblTechnologys');">&nbsp;
					</td>
					<td align="center" width="30px">&nbsp;<span
						name="technologys/technology[${flag}${index}]@seq_no"><x:out
								select="$technology/@seq_no" /></span>&nbsp;
					</td>
					<td align="center" width="200px"><input
						name="technologys/technology[${flag}${index}]/name"
						class="required input_text "  style="width: 150px"
						label="发明专利名称" value="<x:out select="$technology/name"/>" />&nbsp;
					</td>
					<td align="center" width="100px"><input
						name="technologys/technology[${flag}${index}]/way"
						class="required input_text " maxlength=50 style="width: 80px"
						label="专利申请途径" value="<x:out select="$technology/way"/>" />&nbsp;
					</td>
					<td align="center" width="100px"><c:set var="date" scope="page"><x:out select="$technology/application_date" /></c:set>
					<input value="${date}" label="申请日"
						id="technology_application_date_[${flag}${index}]"
						name="technologys/technology[${flag}${index}]/application_date"
						class="required date input_text dateCompareBeforeE:technology_application_date_[${flag}${index}]:technology_authorized_date_[${flag}${index}]" style="width: 64px" />&nbsp;
					</td>
					<td align="center" width="100px"><c:set var="date" scope="page"><x:out select="$technology/authorized_date" /></c:set>
						<input value="${date}" label="授权日"
						id="technology_authorized_date_[${flag}${index}]"
						name="technologys/technology[${flag}${index}]/authorized_date"
						class="required date input_text" style="width: 64px" />&nbsp;
					</td>
					<td align="center"><input
						name="technologys/technology[${flag}${index}]/zhuanli_no"
						class="required input_text " maxlength=50 style="width: 80px"
						label="专利号" value="<x:out select="$technology/zhuanli_no"/>" />&nbsp;
					</td>
					<td align="center" width="100px"><input
						name="technologys/technology[${flag}${index}]/country"
						class="required input_text " maxlength=50 style="width: 80px"
						label="专利授权国家" value="<x:out select="$technology/country"/>" />&nbsp;
					</td>
					<td align="center" width="100px"><input type="radio"
						value="${index+1}" name="technologys_ispatent"
						id="technologys_ispatent_${index}"
						<c:if test="${technologys_ispatent==index+1}">checked="true"</c:if>
						onclick="changeTable('tblTechnologys');initControlValue2(this.id);movePrev2('tblTechnologys')" />&nbsp;
					</td>

				</tr>
				<c:set value="${index+1}" var="index" scope="page" />
			</x:forEach>
			<script type="text/javascript">
				showAllDateTag("tblTechnologys");
			</script>
	</tbody>
</table>
<br>
<table width="98%" align="center">
	<tr>
		<td><input class="button" name="cmdAddbefore" type=button
			value="添加"
			onclick="addNewRow('tblTechnologys');showDateTag('tblTechnologys');">
			<input class="button" name="cmdMovePrev" id="tblTechnologysPrev" type=button value="上移"
			onclick="movePrev('tblTechnologys','selTechnologys');movePrev2('tblTechnologys');"> <input
			class="button" name="cmdMoveNext"  id="tblTechnologysNext" type=button value="下移"
			onclick="moveNext('tblTechnologys','selTechnologys');movePrev2('tblTechnologys');"> <input
			class="button" name="cmddel" type=button value="删除"
			onclick="deleteSelectedRow('tblTechnologys','selTechnologys','国外专利申请记录');del('tblTechnologys','technologys_ispatent')"></td>
	</tr>
</table>
<br />
<div class="t_bar">
	<span class="color_red">*</span>国内发明专利申请明细表
</div>
<table id="tblAuthorizeds" cellpadding="0" class="table01" width="100%"
	border="0" cellpadding="0" style="*border-bottom: #a1c0dc 1px solid;">
	<thead>
		<tr style="border: 1px solid #B7D1E6">
			<th class="TblHead" align="center" width="30px">选择<input
				type="hidden" name="authorizeds/authorizeds_ispatent_value" id="authorizeds_ispatent_value"
				value="<x:out select="$xmlData/data/authorizeds/authorizeds_ispatent_value" />" />
				<c:set var="authorizeds_ispatent">
					<x:out
						select="$xmlData/data/authorizeds/authorizeds_ispatent_value" />
				</c:set></th>
			<th class="TblHead" align="center" width="30px">序号</th>
			<th class="TblHead" align="center" width="250px">发明专利名称</th>
			<th class="TblHead" align="center" width="100px">申请日</th>
			<th class="TblHead" align="center" width="100px">授权日</th>
			<th class="TblHead" align="center" width="150px">专利号</th>
			<th class="TblHead" align="center" width="150px">是否首件授权专利</th>
		</tr>
	</thead>
	<tbody id="tab">
		<tr style="display: none">
			<td align="center">&nbsp;<input type="radio" class="radiobutton"
				name="selAuthorizeds"  onclick="movePrev2('tblAuthorizeds');">
			</td>
			<td align="center"><span
				name="authorizeds|authorized[0]@seq_no">[index]</span>&nbsp;
			</td>
			<td align="center"><input
				name="authorizeds|authorized[0]|name" class="required input_text "
				 style="width: 200px" label="发明专利名称" value="">&nbsp;
			</td>
			<td align="center"><input
				id="authorized_application_date_[0]"
				name="authorizeds|authorized[0]|application_date" label="申请日"
				value="" class="required input_text date dateCompareBeforeE:authorized_application_date_[0]:authorized_authorized_date_[0]" style="width:64px" />&nbsp;
			</td>
			<td align="center"><input
				id="authorized_authorized_date_[0]"
				name="authorizeds|authorized[0]|authorized_date" label="授权日"
				value="" class="required input_text date " style="width: 64px" />&nbsp;
			</td>
			<td align="center"><input
				name="authorizeds|authorized[0]|zhuanli_no"
				class="required input_text " maxlength=50 style="width: 150px"
				label="专利号" value="">&nbsp;
			</td>
			<td align="center" ><input type="radio"
				value="[index]" name="authorizeds_ispatent"
				id="authorizeds_ispatent_[index]"
				onclick="changeTable('tblAuthorizeds');initControlValue2(this.id);movePrev2('tblAuthorizeds')" />&nbsp;
			</td>
			<c:set value="0" var="index" scope="page" />
			<x:forEach select="$xmlData/data/authorizeds/authorized"
				var="authorized">

				<c:choose>
					<c:when test="${index<10}">
						<c:set value="0" var="flag" scope="page" />
					</c:when>
					<c:otherwise>
						<c:set value="" var="flag" scope="page" />
					</c:otherwise>
				</c:choose>
				<tr>
					<td  align="center">&nbsp;<input type="radio"
						class="radiobutton" name="selAuthorizeds"  onclick="movePrev2('tblAuthorizeds');">
					</td>
					<td align="center" ><span
						name="authorizeds/authorized[${flag}${index}]@seq_no"><x:out
								select="$authorized/@seq_no" /></span>&nbsp;
					</td>
					<td align="center" ><input
						name="authorizeds/authorized[${flag}${index}]/name"
						class="required input_text "  style="width: 200px"
						label="发明专利名称" value="<x:out select="$authorized/name"/>" />&nbsp;
					</td>
					<td align="center" ><c:set var="date" scope="page"><x:out select="$authorized/application_date" /></c:set>
					<input value="${date}" label="申请日"
						id="authorized_application_date_[${flag}${index}]"
						name="authorizeds/authorized[${flag}${index}]/application_date"
						class="required date input_text dateCompareBeforeE:authorized_application_date_[${flag}${index}]:authorized_authorized_date_[${flag}${index}]" style="width: 64px" />&nbsp;
					</td>
					<td align="center" ><c:set var="date" scope="page"><x:out select="$authorized/authorized_date" /></c:set>
					<input value="${date}" label="授权日" 
						id="authorized_authorized_date_[${flag}${index}]"
						name="authorizeds/authorized[${flag}${index}]/authorized_date"
						class="required date input_text " style="width: 64px" />&nbsp;
					</td>
					<td align="center" ><input
						name="authorizeds/authorized[${flag}${index}]/zhuanli_no"
						class="required input_text " maxlength=50 style="width: 150px"
						label="专利号" value="<x:out select="$authorized/zhuanli_no"/>" />&nbsp;
					</td>
					<td align="center" ><input type="radio" 
						value="${index+1}" name="authorizeds_ispatent"
						id="authorizeds_ispatent_${index}"
						<c:if test="${authorizeds_ispatent==index+1}">checked="true"</c:if>
						onclick="changeTable('tblAuthorizeds');initControlValue2(this.id);movePrev2('tblAuthorizeds')" />&nbsp;
					</td>

				</tr>
				<c:set value="${index+1}" var="index" scope="page" />
			</x:forEach>
			<script type="text/javascript">
				showAllDateTag("tblAuthorizeds");
			</script>
	</tbody>
</table>
<br>
<table width="98%" align="center">
	<tr>
		<td><input class="button" name="cmdAddbefore" type=button
			value="添加"
			onclick="addNewRow('tblAuthorizeds');showDateTag('tblAuthorizeds');">
			<input class="button" name="cmdMovePrev"  id="tblAuthorizedsPrev" type=button value="上移"
			onclick="movePrev('tblAuthorizeds','selAuthorizeds');movePrev2('tblAuthorizeds')"> <input
			class="button" name="cmdMoveNext" id="tblAuthorizedsNext" type=button value="下移"
			onclick="moveNext('tblAuthorizeds','selAuthorizeds');movePrev2('tblAuthorizeds');"> <input
			class="button" name="cmddel" type=button value="删除"
			onclick="deleteSelectedRow('tblAuthorizeds','selAuthorizeds','国内发明专利申请记录');del('tblAuthorizeds','authorizeds_ispatent')">
		</td>
	</tr>
</table>
<br/>
<div class="t_bar">
	<span class="color_red">*</span>申请资助金额
</div>
<table  cellpadding="0" class="t_css table01" width="100%"
	border="0" cellpadding="0" style="*border-bottom: #a1c0dc 1px solid;">
	<tr>
	<td colspan="2">国内首件授权专利资助不超过0.5万元，非首件授权专利每件资助不超过0.3万元；国外首件授权专利资助不超过5万元，非首件授权专利每件资助不超过3万元。</td>
	</tr>
	<tr>
	<td align="right" width="200px">申请资助金额合计：</td>
	<td width="550px"><input id="total_funds" name="bugdet/total_funds" label="申请资助金额合计" class="required" style="text-align:right" onfocus="InitInput.setNumber(this,7,4,2)" value="<x:out select="$xmlData/data/bugdet/total_funds" />"/>万元</td>
	</tr>
</table>

<script type="text/javascript">
function changeTable(tblId){
	
	
	var trChecked=$("#"+tblId+" :radio:checked").parents("tr").first();//取得被选中的行 
	var index=trChecked.get(0).rowIndex-2;//获得行号
	if(index<1)return false;
	else{
	var trPrev=trChecked.prev();//取得上一行
	for(var i=1;i<index;i++){
		trPrev=trPrev.prev();
	}
	//trChecked.remove();
	trPrev.before(trChecked);
	refreshRowINdex(tblId);
	}
	
}

/**
 * 上移行
 * @param tblId
 * @returns {Boolean}
 */
function movePrev(tblId,radioName){
	
	if($("#"+tblId+" :radio:checked[name="+radioName+"]").length==0){
		scmWarn(irisNotes.prevWarn);
		return false;
	}
	if($("#"+tblId+" tr").length<=2)
		return false;
	var trChecked=$("#"+tblId+" :radio:checked[name="+radioName+"]").parents("tr").first();//取得被选中的行
	
	var trPrev=trChecked.prev();//取得上一行
	var index=trChecked.get(0).rowIndex;//获得行号
	if(index<=2){//如果是第一行
		scmWarn(irisNotes.tabelMoveWarn1);
		return false;
	}
	//trChecked.remove();
	trPrev.before(trChecked);
	trChecked.find(":radio").first().attr("checked",'true');
	refreshRowINdex(tblId);

}

/**
 * 下移行
 * @param tblId
 * @returns {Boolean}
 */
function moveNext(tblId,radioName){
	if($("#"+tblId+" :radio:checked[name="+radioName+"]").length==0){
		scmWarn(irisNotes.nextWarn);
		return false;
	}
	if($("#"+tblId+" tr").length<=2){
		return false;
	}
	
	var trChecked=$("#"+tblId+" :radio:checked[name="+radioName+"]").parents("tr").first();//取得被选中的行  
	var trNext=trChecked.next();
	var index=trChecked.get(0).rowIndex;//获得行号
	if(index==$("#"+tblId+" tr").length-1){//如果是第一行
		scmWarn(irisNotes.tabelMoveWarn2);
		return false;
	}
	//trChecked.remove();
	trNext.after(trChecked);
	trChecked.find(":radio").first().attr("checked","true");
	refreshRowINdex(tblId);
}

 
 
function movePrev2(tblId){
	var trChecked=$("#"+tblId+" :radio:checked").size();
	var tr = $("#"+tblId+" :radio:checked").parents("tr");
	
		if (tr.get(0).rowIndex - 1 == 1&&trChecked==2) {
			$("#"+tblId+"Prev").attr("disabled", "true").css("color", "#808080");
			$("#"+tblId+"Next").attr("disabled", "true").css("color", "#808080");
		} 
		else if (tr.get(0).rowIndex - 1 == 2&&trChecked==2) {
			$("#"+tblId+"Prev").attr("disabled", "true").css("color", "#808080");;
			$("#"+tblId+"Next").removeAttr("disabled").css("color", "#FFFFFF");
		} 
		
		else {
			$("#"+tblId+"Prev").removeAttr("disabled").css("color", "#FFFFFF");
			$("#"+tblId+"Next").removeAttr("disabled").css("color", "#FFFFFF");
			
		}
	
}
function initControlValue2(objId){
	var name="";
	var obj=$("#"+objId);
	name=obj.attr("name");
	if(obj.is(":checked")){
	obj.parents("table").find("input[name$='"+name+"_value'][type='hidden']").val("1");
}
}

function del(tblId,name){
	var trChecked=$("#"+tblId+" :radio:checked").size();
	if(trChecked==0)
	$("#"+name+"_value").val("");
    
	//alert($("#"+name+"_value").val())
}

/**
 * 删除一行
 * @param radioId 
 */
function deleteSelectedRow(tableId,radioName,message,nummin){
	var tr=$("#"+tableId+" :radio:checked[name="+radioName+"]").parents("tr");
   //var trChecked=$("#"+tblId+" :radio:checked").size();
	if(nummin==null)
		nummin=0;
	var length=tr.length;
	if(tr.length==0)
		tr=$("#"+tableId+" tr").filter(":last");
	else if(tr.length>1)
		tr=tr.first();

	if(tr.get(0).rowIndex-1==nummin){
		scmWarn(irisNotes.delWarn1);
		return false;
	}
	if(length==0){
		
			scmWarn(irisNotes.delWarn2);
		
		return false;
	}
	  if(!confirm(messageTip.deleteTip+message+"？"))
		  return false;
	  tr.remove();
	  refreshRowINdex(tableId);
	  return true;
}


	</script>

